﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.Text;
using Xamarin.Forms;

namespace SharedMobilePlatform
{
    public abstract class RaspContentPage : ContentPage
    {
        public static readonly EndpointAddress EndPoint = new EndpointAddress("http://wcf.raspare.se/WcfRaspare.svc");

        protected WcfRaspareClient _client;

        public RaspContentPage(): base()
        {
            BasicHttpBinding binding = CreateBasicHttp();
            _client = new WcfRaspareClient(binding, EndPoint);
            InitializeWcfServiceClient();
        }

        public abstract void InitializeWcfServiceClient();
        //{
            
        //    _client.GetMyDekaederCharacterListCompleted += ClientOnCompleted;
        //}

        private static BasicHttpBinding CreateBasicHttp()
        {
            BasicHttpBinding binding = new BasicHttpBinding
            {
                Name = "basicHttpBinding",
                MaxBufferSize = 2147483647,
                MaxReceivedMessageSize = 2147483647
            };
            TimeSpan timeout = new TimeSpan(0, 2, 30);
            binding.SendTimeout = timeout;
            binding.OpenTimeout = timeout;
            binding.ReceiveTimeout = timeout;
            return binding;
        }

    }
}
